﻿using System.Collections.Generic;
using System.ComponentModel;
using NerdWare.Crm2011VsTools.Core.Crm;
using NerdWare.Crm2011VsTools.DataModel;

namespace NerdWare.Crm2011VsTools.ViewModel
{
    class CrmExplorerViewModel : INotifyPropertyChanged
    {
        private readonly CrmExplorerModel _crmExplorerModel;

        public CrmExplorerViewModel()
        {
            _crmExplorerModel = new CrmExplorerModel();
            Instances = _crmExplorerModel.CrmServer;
        }

        private IEnumerable<IDiscoverCrm> _instances;
        public IEnumerable<IDiscoverCrm> Instances
        {
            get { return _instances; }
            set {
                _instances = value;
                RaisePropertyChanged("Instances");
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string property)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(property));
            }
        }
    }
}
